package edu.zli.lazy;

/**
 * @author ZerlindaLi create at 2021/3/18 13:10
 * @version 1.0.0
 * @description 双重锁检查，避免堵塞
 */
public class LazyDoubleCheckSingle {

    private static LazyDoubleCheckSingle instance;

    private LazyDoubleCheckSingle(){}

    public static LazyDoubleCheckSingle  getInstance(){
        if(instance == null) { // 判断是否需要加锁
            synchronized(LazyDoubleCheckSingle.class) { // 加锁创建实例
                if(instance == null) { // 判断是否需要创建实例
                    instance = new LazyDoubleCheckSingle();
                }
            }
        }
        return instance;
    }

}
